package de.jmda.mview.typeshape.relation;

import java.awt.geom.Line2D;
import java.util.Arrays;
import java.util.List;

/**
 * Direct connection from source to target connector point.
 *
 * @author roger.jmda@gmail.com
 */
public class RECDirect
    extends RelationEndpointConnection
{
	/**
	 * The one and only line of this connection type.
	 */
	private Line2D line = new Line2D.Double();

	/**
	 * Initialises {@link #lines} with its one and only element.
	 *
	 * @param relationEndpointHelperSource
	 * @param relationEndpointHelperTarget
	 */
	public RECDirect(
      RelationEndpointHelper relationEndpointHelperSource,
      RelationEndpointHelper relationEndpointHelperTarget)
  {
	  super(relationEndpointHelperSource, relationEndpointHelperTarget);
  }

	@Override
  protected List<Line2D> getLines()
  {
		return Arrays.asList(line);
  }

	@Override
  protected void update() throws IllegalStateException
  {
	  line.setLine(
	  		relationEndpointHelperSource.getConnectorPoint(),
	  		relationEndpointHelperTarget.getConnectorPoint());
  }
}